function rand() {
	$("body").children(".kainei").remove();
	beginrandom = 1;
	$("#file1").attr("disabled", "disabled");
	$("#file2").attr("disabled", "disabled");
	$("#datainput").attr("disabled", "disabled");
	if (brr.length * 2 <= leftlist.length) {
		var kkk;
		if (count < brr.length * 2) {
			var num = Math.floor(Math.random() * brr.length)
			var tr = $("#randomtable1 tbody").children('tr').eq(brr[num]);
			var td;
			if (man == brr.length) {
				td = tr.children('td').eq(8)
				kkk = "监考员甲";
			} else if (woman == brr.length) {
				td = tr.children('td').eq(7)
				kkk = "监考员乙";
			} else {
				if (arr1[i].性别 == '男') {
					td = tr.children('td').eq(7)
					kkk = "监考员甲";
				} else {
					td = tr.children('td').eq(8)
					kkk = "监考员乙";
				}
			}
			if (td.text() == '') {
				$("#outtable").find("tr:nth-child(" + (arr1[i].序号 + 1) + ")").css("background", "yellow")
				$("#outtable").find("tr:nth-child(" + (arr1[i].序号 + 1) + ")").fadeOut(speed);
				document.getElementById((num + 1) + "").scrollIntoView(false);

				td.text(arr1[i].姓名 + '(' + arr1[i].学院 + ')').addClass("modality").hide()
				td.css("background", "yellow").fadeIn(speed, function() {
					td.css("background", "white").addClass("tdleft");
				})
				$("body").append($("<div></div>").addClass("kainei").html("考场号:" + tr.children('td').eq(1).text() + "   考场位置:" + tr
					.children(
						'td').eq(6).text() + "<br/>" + kkk + ":" + arr1[i].姓名 + '   (' + arr1[i].学院 + ')'));

				if (arr1[i].性别 == '男') {
					man++;
					if (man == brr.length + 1) {
						man = brr.length;
					}
				} else {
					woman++;
					if (woman == brr.length + 1) {
						woman = brr.length;
					}
				}
				if (i == brr.length * 2 - 1) {
					i = brr.length * 2 - 1
				} else if (i == leftlist.length - 1) {
					swal("人员不足!");
					// drawmark = 0;
					// clearInterval(interval);
					// interval = null;
					againrand();
				} else {
					i++
				}
				count++;
			} else {
				rand();
			}

		} else if (count == brr.length * 2 && count < leftlist.length) {
			i++;
			$("#outtable").find("tr:nth-child(" + (arr1[i].序号 + 1) + ")").css("background", "yellow")
			$("#outtable").find("tr:nth-child(" + (arr1[i].序号 + 1) + ")").fadeOut(speed);
			if (sign == 0) {
				for (var k = 0; k < Math.ceil((arr1.length - brr.length * 2) / 10); k++) {
					$("#randomtable2").append(
						"<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td ><td></td></tr>");
					sign++;
				}
			}

			td = $("#randomtable2").children('tr').eq(row).children('td').eq(column).addClass("modality")
			td.text(arr1[i].姓名 + '(' + arr1[i].学院 + ')').addClass("modality").hide()
			td.css("background", "yellow").fadeIn(speed, function() {
				td.css("background", "white").addClass("tdleft");

			})
			

			
			
			

			$("body").append($("<div></div>").addClass("kainei").html("备考教师 :" + arr1[i].姓名 + '   (' + arr1[i].学院 + ')'));

				if (column == 9) {
					if (row == Math.ceil((arr1.length - brr.length * 2) / 10)) {
						row = Math.ceil((arr1.length - brr.length * 2) / 10);
					} else {
						row++;
						column = 0;
					}
				} else {
					column++;
				}
				document.getElementById("randomtable2").scrollIntoView(false);
				if (i == leftlist.length - 1) {
					clearInterval(interval);
					interval = null;
					swal("Good!", "人员随机分配完成!", "success");
					$("body").children(".kainei").remove();
					exsign = 1;
					$("#file1").attr("disabled", false);
					$("#file2").attr("disabled", false);
					$("#datainput").attr("disabled", false);

					//清除按钮后提示文字
					$('#randhint').hide();
					$('#againrandhint').hide();
					drawmark = 0;

					//隐藏左侧表格
					$('#leftlayout').hide();

					//重新设置右侧表格布局
					$('#rightlayout').removeClass("col-md-9");
					$('#rightlayout').addClass("col-md-12");
					document.getElementById("output").scrollIntoView(false);
				}
			}
			else {

				clearInterval(interval);
				interval = null;
				swal("Good!", "人员随机分配完成!", "success");
				// $('#randomtable2').remove();
				$("body").children(".kainei").remove();

				exsign = 1;
				$("#file1").attr("disabled", false);
				$("#file2").attr("disabled", false);
				$("#datainput").attr("disabled", false);

				//清除按钮后提示文字
				$('#randhint').hide();
				$('#againrandhint').hide();
				drawmark = 0;

				//隐藏左侧表格
				$('#leftlayout').hide();

				//重新设置右侧表格布局
				$('#rightlayout').removeClass("col-md-9");
				$('#rightlayout').addClass("col-md-12");
				document.getElementById("output").scrollIntoView(false);
			}

		} else {
			swal("人员不足!");
			// drawmark = 0;
			// clearInterval(interval);
			// interval = null;
			againrand();
		}
	}
